Manages the materials available in the component. More...
Public Member Functions | |
| Material * | createOrRetrieve (const nkMemory::StringView &name, MATERIAL_TYPE type) |
| Material * | get (const nkMemory::StringView &name) |
| Material * | getByIndex (unsigned int id) |
| void | rename (const nkMemory::StringView ¤tName, const nkMemory::StringView &newName) |
| void | erase (const nkMemory::StringView &name) |
Manages the materials available in the component.
At all times, manager owns any memory allocated inside. External code should never delete memory returned by it.
| Material* nkAstraeus::MaterialManager::createOrRetrieve | ( | const nkMemory::StringView & | name, |
| MATERIAL_TYPE | type | ||
| ) |
Creates if unavailable, or retrieves if available, a material.
Depending on the parameter given for the type, the Material instance retrieved will be :
| Value | Pointer type |
|---|---|
| MATERIAL_TYPE::PBS | PbsMaterial |
To address it fully, casting is required. For instance :
| name | The name of the material to retrieve. |
| type | The material type to create. |
| Material* nkAstraeus::MaterialManager::get | ( | const nkMemory::StringView & | name | ) |
Retrieves a material.
| name | The name of the material to retrieve. |
| Material* nkAstraeus::MaterialManager::getByIndex | ( | unsigned int | id | ) |
Get a material, by index. Note that one index can map to a different material after memory is changed. Useful to loop over all available materials in one go.
| id | The index of the material to retrieve. |
| void nkAstraeus::MaterialManager::rename | ( | const nkMemory::StringView & | currentName, |
| const nkMemory::StringView & | newName | ||
| ) |
Renames a material.
| currentName | The name of the material to rename. |
| newName | The name to reassign to the material. |
| void nkAstraeus::MaterialManager::erase | ( | const nkMemory::StringView & | name | ) |
Erases and frees a material.
| name | The name of the material to erase. |